#ifndef UIWIN_GDI_RECT_H_
#define UIWIN_GDI_RECT_H_

namespace uiwin
{
	class DLL_API Size : public tagSIZE
	{
	public:
		Size();
		Size(const SIZE& src);
		Size(const RECT rc);
		Size(int x, int y);
	};

	class DLL_API Point : public tagPOINT
	{
	public:
		Point();
		Point(const POINT& src);
		Point(int x, int y);
		Point(LPARAM lParam);

		BOOL ScreenToClient(HWND hWnd)
		{
			return ::ScreenToClient(hWnd, this);
		}
	};

	class DLL_API Rect : public tagRECT
	{
	public:
		Rect()
		{
			memset(this, 0, sizeof(Rect));
		}
		Rect(const RECT& src)
		{
			left   = src.left;
			top    = src.top;
			right  = src.right;
			bottom = src.bottom;
		}

		bool IntersectRect(Rect* lprcDst, RECT& lprcSrc)
		{
			return ::IntersectRect(lprcDst, this, &lprcSrc) != 0;
		}

		bool isempty() const { return ::IsRectEmpty(this) == TRUE; }

		int width() const { return right - left; }
		int height() const { return bottom - top; }

		void setwidth(int w) 
		{
			right = left + w;
		}
		void setheight(int h)
		{
			bottom = top + h;
		}

		void Offset(int dx, int dy)
		{
			::OffsetRect(this, dx, dy);
		}

		bool haspoint(Point& pt)
		{
			return left <= pt.x && right >= pt.x && 
				top <= pt.y && bottom >= pt.y;
		}
	};
}

#endif	// UIWIN_GDI_RECT_H_